<script setup>
import { ref } from 'vue';
import CharacterSearch from './components/CharacterSearch.vue';
import ChatInterface from './components/ChatInterface.vue';

// 存储当前选定的角色
const selectedCharacter = ref(null);

// 处理角色选择
const handleCharacterSelect = (character) => {
  selectedCharacter.value = character;
};
</script>

<template>
  <el-container class="app-container">
    <el-header class="app-header">
      <div class="header-content">
        <h1 class="app-title">AI 角色扮演对话系统</h1>
        <p class="app-subtitle">与历史名人、文学角色进行智能对话</p>
      </div>
    </el-header>
    
    <el-container>
      <el-aside class="app-aside">
        <CharacterSearch :onCharacterSelect="handleCharacterSelect" />
      </el-aside>
      
      <el-main class="app-main">
        <ChatInterface :selectedCharacter="selectedCharacter" />
      </el-main>
    </el-container>
    
    <el-footer class="app-footer">
      <p>© 2025 AI 角色扮演对话系统 - 让交流超越时空</p>
    </el-footer>
  </el-container>
</template>

<style scoped>
.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
  padding: 20px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
}

.app-title {
  margin: 0 0 10px 0;
  font-size: 28px;
  font-weight: 600;
}

.app-subtitle {
  margin: 0;
  font-size: 16px;
  opacity: 0.9;
}

.app-container > .el-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.app-aside {
  background-color: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.app-footer {
  background-color: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  text-align: center;
  padding: 10px 0;
  color: #666;
  font-size: 14px;
}

/* 响应式布局 */
@media screen and (max-width: 768px) {
  .app-container > .el-container {
    flex-direction: column;
  }
  
  .app-aside {
    height: 300px;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .app-title {
    font-size: 24px;
  }
}
</style>
